IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spWarehouses_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spWarehouses_RetrieveAll'
		DROP  Procedure  spWarehouses_RetrieveAll
	END

GO

PRINT 'Creating Procedure spWarehouses_RetrieveAll'
GO

CREATE Procedure spWarehouses_RetrieveAll
	(
		@Warehouse varchar(50) = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 2007/11/02	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	Warehouses
	
	WHERE	(@Warehouse IS NULL OR Warehouses.Warehouse LIKE @Warehouse + '%')

	-- Return to calling method
	RETURN
GO
